from flask import render_template
from flask_mail import Message
from app import mail


def send_mail(to, subject, template, **kwargs):
    msg = Message(subject)
    msg.sender = "1041448927@qq.com"
    msg.recipients = [to]
    msg.body = render_template(template+".txt", **kwargs)
    msg.html = render_template(template+".html", **kwargs)
    mail.send(msg)
